﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SEAM.Core
{
    public class TraceManager
    {
        public static void WriteExitFunctionToTraceLog()
        {
            WriteToTraceLog("Exit " + new System.Diagnostics.StackTrace().GetFrame(1).GetMethod(), new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().DeclaringType.Name);
        }

        public static void WriteExitFunctionToTraceLog(string category)
        {
            WriteToTraceLog("Exit " + new System.Diagnostics.StackTrace().GetFrame(1).GetMethod());
        }

        public static void WriteEnterFunctionToTraceLog()
        {
            WriteToTraceLog("Begin " + new System.Diagnostics.StackTrace().GetFrame(1).GetMethod(), new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().DeclaringType.Name.ToString());
        }

        public static void WriteEnterFunctionToTraceLog(string category)
        {
            WriteToTraceLog("Begin " + new System.Diagnostics.StackTrace().GetFrame(1).GetMethod());
        }

        public static void WriteToTraceLog(string message)
        {
            WriteToTraceLog(message, new System.Diagnostics.StackTrace().GetFrame(1).GetMethod().DeclaringType.Name.ToString());
        }

        public static void WriteToTraceLog(string message, string category)
        {
            string output = string.Format("{0}\t{1}\t{2}", category, DateTime.Now.ToString("hh:mm:ss:fff"), message);
            System.Diagnostics.Trace.WriteLine(output);
            System.Diagnostics.Trace.Flush();
        }

        public static void Indent()
        {
            System.Diagnostics.Trace.Indent();
        }

        public static void Unindent()
        {
            System.Diagnostics.Trace.Unindent();
        }
    }
}
